//
//  UIBarButtonItem+Extensions.swift
//  weibo
//
//  Created by shizb macbook air on 17/8/1.
//  Copyright © 2017年 YL. All rights reserved.
//

import UIKit
extension UIBarButtonItem{
    convenience init(title:String,fontSize:CGFloat,taget:AnyObject?,action:Selector,isBack:Bool=false) {
        let btn:UIButton=UIButton()
//        btn.frame=CGRect(x: 0, y: 0, width: 45, height: 45)
        btn.setTitle(title, for: .normal)
        btn.titleLabel?.font=UIFont.systemFont(ofSize: fontSize)
        btn.setTitleColor(UIColor.red, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.addTarget(taget, action: action, for: .touchUpInside)
        if isBack {
            
            btn.setImage(UIImage(named:"navigationbar_back_withtext"), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named:"navigationbar_back_withtext_highlighted"), for: .highlighted)
        }
        btn.sizeToFit()

        self.init(customView:btn)
    }
}



















